package com.zhong.gang.applib.http;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.TextView;
import com.zhong.gang.applib.R;


/**
 * Created by ajin on 2018/6/15.
 */

public class LoadingDialog {
    private Dialog dialog;
    private TextView titleTxtv;
    public LoadingDialog(Context context){
//        dialog = new Dialog(context, R.style.Dialog);
//        dialog.setContentView(R.layout.progress_dialog_circle_view);
//        titleTxtv = dialog.findViewById(R.id.tvLoad);
//        dialog.setCancelable(false);

        View view = LayoutInflater.from(context).inflate(R.layout.progress_dialog_circle_view,null);
        titleTxtv = view.findViewById(R.id.tvLoad);
        dialog = new Dialog(context);
        Window dialogWindow = dialog.getWindow();
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(view);
        dialogWindow.setBackgroundDrawableResource(android.R.color.transparent);
        dialogWindow.setGravity(Gravity.CENTER);
        dialog.setCancelable(false);
    }
    public void show(String str){
        if (titleTxtv != null && this.titleTxtv != null)
            this.titleTxtv.setText(str);
        if (dialog != null && !dialog.isShowing()){
            dialog.show();
        }
    }
    public void dismiss(){
        if (dialog != null && dialog.isShowing())
            dialog.dismiss();
    }
}
